<template>
  <div class="banner_container">
    <div class="header_top">
      <div class="header_contet">
        <router-link class="left" to="/login?action=login">登录</router-link>
        <span class="line">|</span>
        <router-link class="right" to="/login?action=register">注册</router-link>
      </div>
    </div>
    <div class="banner_wrap">
      <el-carousel trigger="click" :autoplay="true" :loop="true" height="55vh">
        <el-carousel-item v-for="(item, index) in bannerList" :key="index">
          <img class="banner_item" :src="item" alt="" />
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
import { reactive, toRefs, onMounted } from 'vue';
import { ElCarousel, ElCarouselItem } from 'element-plus';
export default {
  name: 'Banner',
  components: {
    ElCarousel,
    ElCarouselItem,
  },
  setup() {
    const state = reactive({
      bannerList: [],
    });

    onMounted(() => {
      for (let i = 1; i < 6; i++) {
        state.bannerList.push(require(`@/assets/banner/${i}.jpg`));
      }
    });

    return {
      ...toRefs(state),
    };
  },
};
</script>

<style lang="scss" scoped>
.banner_container {
  height: 55vh;
  box-sizing: border-box;
  .header_top {
    position: fixed;
    line-height: 40px;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    background-color: rgba(0, 0, 0, 0.6);
    .header_contet {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      max-width: 1200px;
      margin: 0 auto;
      a {
        color: #bebcbc;
      }
      .line {
        color: #bebcbc;
        margin: 0 15px;
      }
    }
  }

  .banner_wrap {
    position: absolute;
    height: 55vh;
    top: 0;
    left: 0;
    right: 0;
    /deep/ .el-carousel__container {
      .el-carousel__arrow,
      .el-carousel__arrow:hover {
        background-color: rgba(0, 0, 0, 0.5);
        color: #ffffff;
      }
    }
    .banner_item {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
